package com.macro.mall.portal.util;

import com.macro.mall.portal.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * @Author：尚志豪
 * @Package：com.macro.mall.portal.util
 * @Project：mall-swarm-B
 * @name：PreheatTaskScheduler
 * @Date：2024/11/1 17:27
 */
@Component
public class PreheatTaskScheduler {

    @Autowired
    private ProductService productService;

    @Scheduled(cron = "0 0 0 * * ?")
    public void scheduledPreheat() {
        // 获取需要预热的商品 ID 列表
        List<Long> productIds = Arrays.asList(1L, 2L, 3L);
        productService.preheatProducts(productIds);
    }
}
